<html>
<head><meta charset="utf-8"><title>well-formed consts and cannot find value · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html">well-formed consts and cannot find value</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212182909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212182909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212182909">(Oct 03 2020 at 18:04)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> while I have you... I'm also seeing this. I swear I saw someone mentioning the same problem recently, but can't find it now.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_generics, const_evaluatable_checked)]</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">ArrayExt</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">xsplit_at</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">M</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="p">(</span><span class="o">&amp;</span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">M</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">M</span><span class="w"> </span><span class="p">}]);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">ArrayExt</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">xsplit_at</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">A</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="p">(</span><span class="o">&amp;</span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">A</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">}])</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="kd">let</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">as_ptr</span><span class="p">();</span><span class="w"></span>
<span class="w">            </span><span class="kd">let</span><span class="w"> </span><span class="n">head</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">A</span><span class="p">];</span><span class="w"></span>
<span class="w">            </span><span class="kd">let</span><span class="w"> </span><span class="n">tail</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="n">A</span><span class="p">)</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">A</span><span class="p">];</span><span class="w"></span>
<span class="w">            </span><span class="p">(</span><span class="o">&amp;*</span><span class="n">head</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;*</span><span class="n">tail</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>

<p><a href="https://play.integer32.com/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=33c45e376d4c263e2cd6e34acb9f4efb">playground</a></p>
<div class="codehilite" data-code-language="none"><pre><span></span><code>error[E0412]: cannot find type `T` in this scope
 --&gt; src/lib.rs:4:56
  |
4 |     fn xsplit_at&lt;const M: usize&gt;(&amp;self) -&gt; (&amp;[T; M], &amp;[T; { N - M }]);
  |                                                        ^ not found in this scope

error[E0425]: cannot find value `N` in this scope
 --&gt; src/lib.rs:4:61
  |
4 |     fn xsplit_at&lt;const M: usize&gt;(&amp;self) -&gt; (&amp;[T; M], &amp;[T; { N - M }]);
  |                        -                                    ^
  |                        |
  |                        similarly named const parameter `M` defined here
</code></pre></div>



<a name="212182933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212182933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212182933">(Oct 03 2020 at 18:05)</a>:</h4>
<p>isn*t this simply that inner functions can't mention generic parameters of outer functions?</p>



<a name="212182943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212182943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212182943">(Oct 03 2020 at 18:05)</a>:</h4>
<p>what's the outer function?</p>



<a name="212182952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212182952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212182952">(Oct 03 2020 at 18:05)</a>:</h4>
<p>????</p>



<a name="212182953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212182953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212182953">(Oct 03 2020 at 18:06)</a>:</h4>
<p>what</p>



<a name="212183006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183006">(Oct 03 2020 at 18:06)</a>:</h4>
<p>looks like my brain broke for a few seconds here</p>



<a name="212183007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183007">(Oct 03 2020 at 18:06)</a>:</h4>
<p>I mean, I only have one function at all, as far as I can see.</p>



<a name="212183015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183015">(Oct 03 2020 at 18:06)</a>:</h4>
<p>You do have to declare <code>T</code> and <code>N</code> when using them in the trait def</p>



<a name="212183022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183022">(Oct 03 2020 at 18:07)</a>:</h4>
<p>ah yeah</p>



<a name="212183029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183029">(Oct 03 2020 at 18:07)</a>:</h4>
<p>ArrayExt doesn't define <code>T</code></p>



<a name="212183030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183030">(Oct 03 2020 at 18:07)</a>:</h4>
<p>this works <a href="https://play.integer32.com/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=d1270b675f48680c3c299ac9bb13428c">https://play.integer32.com/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=d1270b675f48680c3c299ac9bb13428c</a></p>



<a name="212183033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183033">(Oct 03 2020 at 18:07)</a>:</h4>
<p>you probably want to use <code>Self</code> there</p>



<a name="212183054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183054">(Oct 03 2020 at 18:08)</a>:</h4>
<p>Where would I use <code>Self</code>?</p>



<a name="212183099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183099">(Oct 03 2020 at 18:08)</a>:</h4>
<p>gimme a sec</p>



<a name="212183104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183104">(Oct 03 2020 at 18:08)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> That makes sense. Now to figure out why I didn't reason that out based on the error messages.</p>



<a name="212183122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183122">(Oct 03 2020 at 18:09)</a>:</h4>
<p>do we need GATs here?</p>



<a name="212183127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183127">(Oct 03 2020 at 18:09)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_generics, const_evaluatable_checked)]</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">ArrayExt</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Head</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Tail</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">xsplit_at</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">M</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="p">(</span><span class="o">&amp;</span><span class="bp">Self</span>::<span class="n">Head</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="bp">Self</span>::<span class="n">Tail</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">ArrayExt</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">N</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Head</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">A</span><span class="p">];</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Tail</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">A</span><span class="p">];</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">xsplit_at</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">A</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="p">(</span><span class="o">&amp;</span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">A</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">}])</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="kd">let</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">as_ptr</span><span class="p">();</span><span class="w"></span>
<span class="w">            </span><span class="kd">let</span><span class="w"> </span><span class="n">head</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">A</span><span class="p">];</span><span class="w"></span>
<span class="w">            </span><span class="kd">let</span><span class="w"> </span><span class="n">tail</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="n">A</span><span class="p">)</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">A</span><span class="p">];</span><span class="w"></span>
<span class="w">            </span><span class="p">(</span><span class="o">&amp;*</span><span class="n">head</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;*</span><span class="n">tail</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="212183181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183181">(Oct 03 2020 at 18:10)</a>:</h4>
<p>would be my idea, but we only define <code>A</code> in <code>xsplit_at</code> so we can't reference it in associated types</p>



<a name="212183190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183190">(Oct 03 2020 at 18:10)</a>:</h4>
<p>I don't see why GATs would be needed. as we wouldn't be parameterizing over lifetimes.</p>



<a name="212183200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183200">(Oct 03 2020 at 18:10)</a>:</h4>
<p>Or do you mean The Real GATs</p>



<a name="212183202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183202">(Oct 03 2020 at 18:10)</a>:</h4>
<p>even with types.</p>



<a name="212183205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183205">(Oct 03 2020 at 18:10)</a>:</h4>
<p>yeah</p>



<a name="212183217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183217">(Oct 03 2020 at 18:11)</a>:</h4>
<p><code>type Tail&lt;const A: usize&gt; = [T; N - A]</code></p>



<a name="212183225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183225">(Oct 03 2020 at 18:11)</a>:</h4>
<p>Why would you go that path instead of the generics in the trait?</p>



<a name="212183247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183247">(Oct 03 2020 at 18:11)</a>:</h4>
<p>because with generics on the trait you cant write <code>arr.xsplit_at::&lt;3&gt;()</code></p>



<a name="212183251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183251">(Oct 03 2020 at 18:11)</a>:</h4>
<p>afaict</p>



<a name="212183523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183523">(Oct 03 2020 at 18:16)</a>:</h4>
<p><a href="https://play.integer32.com/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=125c0d8141209c74f8993fc861d680dc">Seems to compile fine</a></p>



<a name="212183634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183634">(Oct 03 2020 at 18:19)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="212183704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183704">(Oct 03 2020 at 18:20)</a>:</h4>
<p>not sure what I was thinking here. That seems good to me! Even if it's somewhat unfortunate that this is needed</p>



<a name="212183731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183731">(Oct 03 2020 at 18:21)</a>:</h4>
<p>That was my idea <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ad2585bd751942c55b32be60ffe280ef">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ad2585bd751942c55b32be60ffe280ef</a></p>



<a name="212183777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183777">(Oct 03 2020 at 18:22)</a>:</h4>
<p>which instead duplicates the generic param of the function itself</p>



<a name="212183787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183787">(Oct 03 2020 at 18:22)</a>:</h4>
<p>which might make this slightly more usable in generic contexts, but I don't think this matters here</p>



<a name="212183809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183809">(Oct 03 2020 at 18:23)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error: any use of this value will cause an error
  --&gt; src/main.rs:29:5
   |
29 |     const N2: usize;
   |     ^^^^^^^^^^^^^^^^ no MIR body is available for DefId(0:24 ~ playground[a78a]::FromBytesLittleEndian::N2)
   |
   = note: `#[deny(const_err)]` on by default
</code></pre></div>


<p>Nice.</p>



<a name="212183816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183816">(Oct 03 2020 at 18:23)</a>:</h4>
<p>but it also is kind of weird to implement a trait for a method where the method is sometimes not available</p>



<a name="212183818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183818">(Oct 03 2020 at 18:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116155">Jake Goulding</span> <a href="#narrow/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value/near/212183809">said</a>:</p>
<blockquote>
<div class="codehilite"><pre><span></span><code>error: any use of this value will cause an error
  --&gt; src/main.rs:29:5
   |
29 |     const N2: usize;
   |     ^^^^^^^^^^^^^^^^ no MIR body is available for DefId(0:24 ~ playground[a78a]::FromBytesLittleEndian::N2)
   |
   = note: `#[deny(const_err)]` on by default
</code></pre></div>


<p>Nice.</p>
</blockquote>
<p>nice</p>



<a name="212183823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183823">(Oct 03 2020 at 18:23)</a>:</h4>
<p>what's the complete code here?</p>



<a name="212183939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183939">(Oct 03 2020 at 18:26)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> <a href="https://play.integer32.com/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=e2d3ed857a2c5fff24d7243329c096c7">https://play.integer32.com/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=e2d3ed857a2c5fff24d7243329c096c7</a></p>



<a name="212183982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212183982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212183982">(Oct 03 2020 at 18:27)</a>:</h4>
<p>And <a href="https://play.integer32.com/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=7543d05321e448620de12648fb7c713a">now</a> I get:</p>
<div class="codehilite"><pre><span></span><code>error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(&lt;^0 as FromBytesLittleEndian&gt;)` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen/mod.rs:65:32

error: internal compiler error: ty::ConstKind::Error constructed but no error reported.
  |
  = note: delayed at /rustc/8876ffc9235dade728e1fbc4be4c85415fdd0bcd/compiler/rustc_middle/src/ty/consts.rs:183:43

error: internal compiler error: `ErrorReported` without an error
  --&gt; src/main.rs:78:53
   |
78 |             a: FromBytesLittleEndian::from_bytes_le(a),
   |                                                     ^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:754:31

error: internal compiler error: `ErrorReported` without an error
  --&gt; src/main.rs:79:53
   |
79 |             b: FromBytesLittleEndian::from_bytes_le(b),
   |                                                     ^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:754:31

error: internal compiler error: `ErrorReported` without an error
  --&gt; src/main.rs:80:53
   |
80 |             c: FromBytesLittleEndian::from_bytes_le(c),
   |                                                     ^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:754:31
</code></pre></div>



<a name="212184029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212184029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212184029">(Oct 03 2020 at 18:28)</a>:</h4>
<p>It's almost as if this feature isn't finished.</p>



<a name="212184033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212184033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212184033">(Oct 03 2020 at 18:28)</a>:</h4>
<p>~surprising~</p>



<a name="212184042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212184042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212184042">(Oct 03 2020 at 18:28)</a>:</h4>
<p>but thanks for finding these <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="212184214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212184214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212184214">(Oct 03 2020 at 18:32)</a>:</h4>
<p>Here's what I really want to be able to write:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[derive(Debug, /* FromBytesLittleEndian */)]</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">Header</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">a</span>: <span class="kt">u32</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">b</span>: <span class="kt">u16</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">c</span>: <span class="kt">u8</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">FromBytesLittleEndian</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Header</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span> <span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="o">&lt;</span><span class="kt">u32</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">FromBytesLittleEndian</span><span class="o">&gt;</span>::<span class="n">N</span><span class="w"></span>
<span class="w">            </span><span class="o">+</span><span class="w"> </span><span class="o">&lt;</span><span class="kt">u16</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">FromBytesLittleEndian</span><span class="o">&gt;</span>::<span class="n">N</span><span class="w"></span>
<span class="w">            </span><span class="o">+</span><span class="w"> </span><span class="o">&lt;</span><span class="kt">u8</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">FromBytesLittleEndian</span><span class="o">&gt;</span>::<span class="n">N</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>

<span class="w">    </span><span class="k">fn</span> <span class="nf">from_bytes_le</span><span class="p">(</span><span class="n">rest</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="bp">Self</span>::<span class="n">N</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">rest</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rest</span><span class="p">.</span><span class="n">xsplit_at</span>::<span class="o">&lt;</span><span class="p">{</span><span class="w"> </span><span class="o">&lt;</span><span class="kt">u32</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">FromBytesLittleEndian</span><span class="o">&gt;</span>::<span class="n">N</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="n">rest</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rest</span><span class="p">.</span><span class="n">xsplit_at</span>::<span class="o">&lt;</span><span class="p">{</span><span class="w"> </span><span class="o">&lt;</span><span class="kt">u16</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">FromBytesLittleEndian</span><span class="o">&gt;</span>::<span class="n">N</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="n">rest</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rest</span><span class="p">.</span><span class="n">xsplit_at</span>::<span class="o">&lt;</span><span class="p">{</span><span class="w"> </span><span class="o">&lt;</span><span class="kt">u8</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">FromBytesLittleEndian</span><span class="o">&gt;</span>::<span class="n">N</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>

<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">_assert_consumed_all_bytes</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rest</span><span class="p">;</span><span class="w"></span>

<span class="w">        </span><span class="bp">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">a</span>: <span class="nc">FromBytesLittleEndian</span>::<span class="n">from_bytes_le</span><span class="p">(</span><span class="n">a</span><span class="p">),</span><span class="w"></span>
<span class="w">            </span><span class="n">b</span>: <span class="nc">FromBytesLittleEndian</span>::<span class="n">from_bytes_le</span><span class="p">(</span><span class="n">b</span><span class="p">),</span><span class="w"></span>
<span class="w">            </span><span class="n">c</span>: <span class="nc">FromBytesLittleEndian</span>::<span class="n">from_bytes_le</span><span class="p">(</span><span class="n">c</span><span class="p">),</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="212184716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212184716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212184716">(Oct 03 2020 at 18:45)</a>:</h4>
<p>And <a href="https://play.integer32.com/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=235d58d9d986de1900376987a31f8269">reordering it a bit</a>:</p>
<div class="codehilite"><pre><span></span><code>error[E0308]: mismatched types
  --&gt; src/main.rs:74:54
   |
74 |         let a = FromBytesLittleEndian::from_bytes_le(a);
   |                                                      ^ expected `Self::N`, found `Self::N`
   |
   = note: expected reference `&amp;[u8; _]`
              found reference `&amp;[u8; _]`

error[E0308]: mismatched types
  --&gt; src/main.rs:76:25
   |
76 |         let (b, rest) = rest.xsplit_at();
   |                         ^^^^^^^^^^^^^^^^ expected `{ N - M }`, found `{ N - M }`
   |
   = note: expected type `_`
             found tuple `(&amp;[u8; _], &amp;[u8; _])`
</code></pre></div>



<a name="212184757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212184757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212184757">(Oct 03 2020 at 18:46)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> is it worth me doing anything with these various errors?</p>



<a name="212184796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212184796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212184796">(Oct 03 2020 at 18:47)</a>:</h4>
<p>ping me when you find them, I currently add them to a list in the tracking issue <a href="https://github.com/rust-lang/rust/issues/76560">#76560</a></p>



<a name="212184846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212184846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212184846">(Oct 03 2020 at 18:48)</a>:</h4>
<p>I don't think we should open a new issue in the rust repo for them, as there are a lot of them and they aren't really relevant for anyone but me <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>
<p><em>edit: or maybe we should, not completely sure about this <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></em></p>



<a name="212185219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212185219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212185219">(Oct 03 2020 at 18:58)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> I'm not immediately seeing a bullet point for the "mismatched types" one</p>



<a name="212185232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212185232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212185232">(Oct 03 2020 at 18:59)</a>:</h4>
<p><a href="https://play.integer32.com/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=c127bb01b6641153113969305256af10">current example</a></p>



<a name="212185326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212185326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212185326">(Oct 03 2020 at 19:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116155">Jake Goulding</span> <a href="#narrow/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value/near/212185219">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> I'm not immediately seeing a bullet point for the "mismatched types" one</p>
</blockquote>
<p>just added that one</p>



<a name="212185333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212185333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212185333">(Oct 03 2020 at 19:01)</a>:</h4>
<p>added three additional - still broken - tests thanks to you <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>



<a name="212185401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212185401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212185401">(Oct 03 2020 at 19:03)</a>:</h4>
<p>the current example looks sufficiently similar to the previous version so I don't think it makes sense to track that one too for now</p>



<a name="212186113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212186113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212186113">(Oct 03 2020 at 19:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value/near/212185333">said</a>:</p>
<blockquote>
<p>added three additional - still broken - tests thanks to you <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>
</blockquote>
<div class="message_inline_image"><a href="https://i.imgflip.com/1pk2po.jpg"><img src="https://i.imgflip.com/1pk2po.jpg"></a></div>



<a name="212186141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/well-formed%20consts%20and%20cannot%20find%20value/near/212186141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value.html#212186141">(Oct 03 2020 at 19:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/122651-general/topic/well-formed.20consts.20and.20cannot.20find.20value/near/212185401">said</a>:</p>
<blockquote>
<p>the current example looks sufficiently similar to the previous version so I don't think it makes sense to track that one too for now</p>
</blockquote>
<p>yes, I was just providing it again so you didn't have to scroll back :-)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>